package com.example.bluetoothexample;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyCustomBaseAdapter extends BaseAdapter {
	 private static ArrayList<SettingsResult> menuItems;
	 
	 private LayoutInflater mInflater;

	 public MyCustomBaseAdapter(Context context, ArrayList<SettingsResult> results) {
	  menuItems = results;
	  mInflater = LayoutInflater.from(context);
	 }

	 public int getCount() {
	  return menuItems.size();
	 }

	 public Object getItem(int position) {
	  return menuItems.get(position);
	 }

	 public long getItemId(int position) {
	  return position;
	 }

	 public View getView(int position, View convertView, ViewGroup parent) {
	  ViewHolder holder;
	  if (convertView == null) 
	  {
		   convertView = mInflater.inflate(R.layout.custom_row_view, null);
		   holder = new ViewHolder();
		   holder.title = (TextView) convertView.findViewById(R.id.title);
		   holder.text1 = (TextView) convertView.findViewById(R.id.text1);
		   holder.text2 = (TextView) convertView.findViewById(R.id.text2);
		   holder.text3 = (TextView) convertView.findViewById(R.id.text3);
	
		   convertView.setTag(holder);
	  } 
	  else 
	  {
		  holder = (ViewHolder) convertView.getTag();
	  }
	  
		  holder.title.setText(menuItems.get(position).getTitle());
		  holder.text1.setText(menuItems.get(position).getText1());
		  holder.text2.setText(menuItems.get(position).getText2());
		  holder.text3.setText(menuItems.get(position).getText3());

		  return convertView;
	 }
	 
	 static class ViewHolder 
	 {
		  TextView title;
		  TextView text1;
		  TextView text2;
		  TextView text3;
	 }
}